// index.js
// 获取应用实例
const app = getApp()

Page({
  data: {
    /* 抽奖 data */
    defaultConfig: {
      isImg: true, // 是否使用图片
    },
    luckyList: [{
        id: 0,
        isBtn: false,
        title: '1元',
        color: '',
        background: '',
        img: '/assets/img/periphery/1.svg', // 默认图片
        imgWidth: '',
        imgHeight: '',
        luckyImg: '/assets/img/periphery/2.svg', // 中奖后的图片
      },
      {
        id: 1,
        isBtn: false,
        title: '2元',
        color: '',
        background: '',
        img: '/assets/img/periphery/1.svg',
        imgWidth: '',
        imgHeight: '',
        luckyImg: '/assets/img/periphery/2.svg', // 中奖后的图片
      },
      {
        id: 2,
        isBtn: false,
        title: '3元',
        color: '',
        background: '',
        img: '/assets/img/periphery/1.svg',
        imgWidth: '',
        imgHeight: '',
        luckyImg: '/assets/img/periphery/2.svg', // 中奖后的图片
      },
      {
        id: 3,
        isBtn: false,
        title: '4元',
        color: '',
        background: '',
        img: '/assets/img/periphery/1.svg',
        imgWidth: '',
        imgHeight: '',
        luckyImg: '/assets/img/periphery/2.svg', // 中奖后的图片
      },
      {
        id: 4,
        isBtn: false,
        title: '5元',
        color: '',
        background: '',
        img: '/assets/img/periphery/1.svg',
        imgWidth: '',
        imgHeight: '',
        luckyImg: '/assets/img/periphery/2.svg', // 中奖后的图片
      },
      {
        id: 5,
        isBtn: false,
        title: '6元',
        color: '',
        background: '',
        img: '/assets/img/periphery/1.svg',
        imgWidth: '',
        imgHeight: '',
        luckyImg: '/assets/img/periphery/2.svg', // 中奖后的图片
      },
      {
        id: 6,
        isBtn: false,
        title: '7元',
        color: '',
        background: '',
        img: '/assets/img/periphery/1.svg',
        imgWidth: '',
        imgHeight: '',
        luckyImg: '/assets/img/periphery/2.svg', // 中奖后的图片
      },
      {
        id: 7,
        isBtn: false,
        title: '8元',
        color: '',
        background: '',
        img: '/assets/img/periphery/1.svg',
        imgWidth: '',
        imgHeight: '',
        luckyImg: '/assets/img/periphery/2.svg', // 中奖后的图片
      }
    ],
    buttons: {
      isBtn: true, // 是否按钮
      background: '',
      img: '/assets/img/periphery/luckyBtn.png',
      imgWidth: '',
      imgHeight: '',
      fonts: [
        /* {
                title: '立即抽奖',
                top: '-8%',
                color: '#fff',
                fontSize: '30rpx',
                fontWeight: ''
              }, {
                title: '5积分抽一次',
                top: '15%',
                color: '#000',
                fontSize: '24rpx',
                fontWeight: ''
              } */
      ]
    },
    show: false,
    show2: false,
    /* 抽奖 data */
  },
  onLoad() {
    this.getLuckData()
  },
  getLuckData() {
    let _this = this
    setTimeout(function () {
      // 模拟获取数据
      let idx = _this.data.luckyList.length / 2
      let newlist = _this.data.luckyList
      newlist.splice(idx, 0, _this.data.buttons)
      _this.setData({
        luckyList: newlist
      })
    }, 800)
  },
  end(obj) {
    // 中奖 回调
    console.log(obj)
    wx.showModal({
      title: '恭喜获奖',
      content: '恭喜获得' + obj.detail.title
    })
  },
})